import pickle
import sys 
sys.path.append('..')
from common.util import analogy, most_similar


pkl_file = 'cbow_params.pkl'

with open(pkl_file,'rb') as f:
    params = pickle.load(f)
    word_vecs = params['word_vecs']
    word_to_id = params['word_to_id']
    id_to_word = params['id_to_word']

querys = ['you','year','car','toyata']
for query in querys:
    most_similar(query,word_to_id,id_to_word,word_vecs,high=5)

# analogy task
print('-'*50)
analogy('king', 'man', 'queen',  word_to_id, id_to_word, word_vecs)
analogy('take', 'took', 'go',  word_to_id, id_to_word, word_vecs)
analogy('car', 'cars', 'child',  word_to_id, id_to_word, word_vecs)
analogy('good', 'better', 'bad',  word_to_id, id_to_word, word_vecs)